from contract import CapitalGoods
from utils import p, INI_YEAR

batch_capital = []
arg_v = 0
for t in range(1, int(p.para.duration_or_capital) + 1):
    arg_v += t / (p.para.duration_or_capital * (1 + p.ss.steady_state_rate) ** (p.para.duration_or_capital - t))

k = p.c.capital_of_consumption_firm / p.n.number_of_c_firms

p_k = p.p.price_of_capital
for t in range(1, int(p.para.duration_or_capital) + 1):
    arg_v = t / p.para.duration_or_capital
    p_capital = p_k / (1 + p.ss.steady_state_rate) ** (p.para.duration_or_capital - t)
    share = arg_v
    capital_t = CapitalGoods(
        year=INI_YEAR - (p.para.duration_or_capital - t + 1),
        quantity=k / p.para.duration_or_capital,
        price=p_capital,
        share=share
        )
    batch_capital.append(capital_t)

c_goods_value_sum = 0
for c_goods in batch_capital:
    v = c_goods.quantity * c_goods.share
    c_goods_value_sum += v

c_goods_value_sum_price = 0
for c_goods in batch_capital:
    v = c_goods.price * c_goods.quantity * c_goods.share
    c_goods_value_sum_price += v

print(k, c_goods_value_sum, c_goods_value_sum_price)